# matrix = [[1,1,1],[1,0,1],[1,1,1]]
matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
def setZeroes(matrix):
    rowSet=[]
    colSet=[]
    matrixRow=len(matrix)
    matrixCol=len(matrix[0])
    #把为0的行和列的值记录在列表中
    for i in range(matrixRow):
        for j in range(matrixCol):
            if matrix[i][j]==0:
                rowSet.append(i)
                colSet.append(j)
    #把列表转换成集合来存储
    rowSet=set(rowSet)
    colSet=set(colSet)
    #进行置0操作
    for i in range(matrixRow):
        for j in range(matrixCol):
            if i in rowSet or j in colSet:
                matrix[i][j]=0
    return matrix
print(setZeroes(matrix))




